
package ch.hearc.coursJava.kitBase.exception;

public class UseCercleLigneCommande
	{

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/

	/**
	 * HYP : args[0] contient le rayon du cercle
	 */
	public static void main(String[] args)
		{
		double rayon = toRayon(args);

		if (rayon >= 0)
			{
			solve(rayon);
			}
		else
			{
			System.out.println("Error rayon negatif!");
			}
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/

	private static double toRayon(String[] args)
		{
		try
			{
			return Double.parseDouble(args[0]);
			}
		catch (Exception e)
			{
			System.out.println("Parametre entrer invalie");
			System.exit(-1); // 0 normal, -1 anormal
			return -1;
			}
		}

	private static void solve(double rayon)
		{
		double aire = CercleTools.aire(rayon);
		double perimetre = CercleTools.perimetre(rayon);

		System.out.println("aire = " + aire);
		System.out.println("perimetre = " + perimetre);
		}

	}
